home *** CD-ROM | disk | FTP | other *** search
/ Kompuutteri K-CD 2002 #1 / K-CD_2002-01.iso / Delphi / INSTALL / program files / Borland / Delphi6 / Demos / Swat / options.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2001-05-22  |  1.4 KB  |  62 lines

  1. unit options;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   StdCtrls, ComCtrls, ExtCtrls;
  8.  
  9. type
  10.   TOptionsDlg = class(TForm)
  11.     Bevel1: TBevel;
  12.     Slow: TLabel;
  13.     Fast: TLabel;
  14.     Label1: TLabel;
  15.     Label2: TLabel;
  16.     Speed: TLabel;
  17.     Population: TLabel;
  18.     Time: TLabel;
  19.     OKBtn: TButton;
  20.     CancelBtn: TButton;
  21.     SpeedSet: TTrackBar;
  22.     PopulationSet: TTrackBar;
  23.     GameTimeSet: TEdit;
  24.     procedure OKBtnClick(Sender: TObject);
  25.     procedure FormShow(Sender: TObject);
  26.   private
  27.     { Private declarations }
  28.   public
  29.     { Public declarations }
  30.   end;
  31.  
  32. var
  33.   OptionsDlg: TOptionsDlg;
  34.  
  35. implementation
  36.  
  37. uses Main;
  38.  
  39. {$R *.dfm}
  40.  
  41. procedure TOptionsDlg.OKBtnClick(Sender: TObject);
  42. begin
  43.   SwatForm.LiveTime := SpeedSet.Max + 1 - SpeedSet.Position;
  44.   SwatForm.Frequence := PopulationSet.Position;
  45.   SwatForm.GameTime := StrToInt(GameTimeSet.Text);
  46.  
  47.   // limit the value of GameTime to a reasonable length
  48.   if (SwatForm.GameTime < 1) then
  49.     SwatForm.GameTime := 150;
  50.   if (SwatForm.GameTime > 9999) then
  51.     SwatForm.GameTime := 9999;
  52. end;
  53.  
  54. procedure TOptionsDlg.FormShow(Sender: TObject);
  55. begin
  56.   SpeedSet.Position := SpeedSet.Max + 1 - SwatForm.LiveTime;
  57.   PopulationSet.Position := SwatForm.Frequence;
  58.   GameTimeSet.Text := inttoStr(SwatForm.GameTime);
  59. end;
  60.  
  61. end.
  62.